﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Drawing;
using System.Windows.Interop;

namespace GSdk.SkypePlugin
{
    /// <summary>
    /// Logica di interazione per ConfigureWindowxaml.xaml
    /// </summary>
    public partial class ConfigureWindow : Window
    {
        public ConfigureWindow(double secondsPerWord = 1.0, bool showWhenMessageIncoming = true, bool useMessageSeparator = true, string messageSeparator = null)
        {
            InitializeComponent();

            Icon = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.LCDMedia_SkypePluginAppIcon.ToBitmap().GetHbitmap(), IntPtr.Zero, Int32Rect.Empty,                    BitmapSizeOptions.FromEmptyOptions());
            ResetSettings(secondsPerWord, showWhenMessageIncoming, useMessageSeparator, messageSeparator);
        }

        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }

        public bool ShowWhenMessageIncoming { get { return (showWhenMessageIncomingCheckbox.IsChecked.HasValue ? showWhenMessageIncomingCheckbox.IsChecked.Value : false); } }
        public double SecondsPerWord { get { return SecondsPerWordSlider.Value; } }
        public string MessageSeparator { get { return m_MessageSeparatorTextbox.IsEnabled ? m_MessageSeparatorTextbox.Text : " "; } }
        public bool UseMessageSeparator { get { return m_UseMessageSeparator.IsChecked.HasValue ? m_UseMessageSeparator.IsChecked.Value : true; } }

        private void m_Reset_Click(object sender, RoutedEventArgs e)
        {
            ResetSettings();
            DialogResult = true;
        }

        public void ResetSettings(double secondsPerWord = 1.0, bool showWhenMessageIncoming = true, bool useMessageSeparator = true, string messageSeparator = null)
        {
            SecondsPerWordSlider.Value = secondsPerWord;
            showWhenMessageIncomingCheckbox.IsChecked = showWhenMessageIncoming;
            m_UseMessageSeparator.IsChecked = useMessageSeparator;
            m_MessageSeparatorTextbox.Text = messageSeparator ?? " ";
        }
    }
}
